package com.epin.business.commons.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.pagination.Pagination;
import com.epin.business.commons.entity.ForeignKey;
import com.epin.business.commons.entity.bo.ForeignKeyField;
import com.epin.business.commons.entity.bo.ForeignKeyNormal;


/**
 * <p>
  * 表伪外键记录表 Mapper 接口
 * </p>
 *
 * @author fujiajun
 * @since 2017-09-08
 */
public interface ForeignKeyMapper extends BaseMapper<ForeignKey> {
	
	
	/**
	 * <p>根据SQL查找列表</p>
	 * 
	 * @param page 分页辅助器
	 * @param params 参数表
	 * 
	 * <p>
	 * 	参数表可填参数：
	 * 		<p>keyword 关键字</p>
	 * </p>
	 * 
	 * @return List<>
	 * 
	 * @author fujiajun
	 * @since 2017-09-08
	 */
	List<ForeignKeyNormal> selectForeignKeyVoList(Pagination page, Map<String, Object> params);
	
	
	/**
	 * <p>根据待检表名查找列表</p>
	 * 
	 * @param tableName 待检表名
	 * 
	 * @return List<>
	 * 
	 * @author fujiajun
	 * @since 2017-11-08
	 */
	List<ForeignKeyNormal> selectForeignKeyByTable(@Param("tableName")String tableName);
	
	
	/**
	 * <p>根据ID获取表名</p>
	 * 
	 * @param id 数据ID
	 * 
	 * @return String
	 * 
	 * @author fujiajun
	 * @since 2017-09-08
	 */
	String selectTableById(@Param("id")Integer id);

	
	/**
	 * <p>计算某个表的某个字段的记录数</p>
	 * 
	 * @param table 待检表名
	 * @param referenceTable 参考表名
	 * @param fields 字段名列表
	 * @param id 记录标记
	 * 
	 * @return int
	 * 
	 * @author fujiajun
	 * @since 2017-09-08
	 */
	int countTableFieldRecords(@Param("table")String table, @Param("referenceTable")String referenceTable, 
			@Param("fields")List<ForeignKeyField> fields, @Param("id")String id);
	
}
